/**
 * 
 */
package com.scpii.universal.pns.dao.impl;

import org.springframework.stereotype.Repository;

import com.scpii.universal.hibernate.dao.impl.BaseDaoImpl;
import com.scpii.universal.pns.dao.EcProductDao;
import com.scpii.universal.pns.entity.EcProduct;

/**
 * genericWeb
 * 
 * @author acer 2012-7-5下午04:35:11
 */
@Repository
public class EcProductDaoImpl extends BaseDaoImpl<EcProduct, Long> implements
		EcProductDao {

	@Override
	public void delete(Long id) {
		String hql = "delete from EcProduct e where e.id=?";
		getHibernateTemplate().getSessionFactory().getCurrentSession()
				.createQuery(hql).setParameter(0, id).executeUpdate();
	}

	@Override
	public Short getMaxSortOrder(Long intCateId) {
		String hql = "select max(e.sortOrders) from EcProduct e where e.catId=?";
		Short maxSortOrder = (Short) getHibernateTemplate().getSessionFactory()
				.getCurrentSession().createQuery(hql)
				.setParameter(0, intCateId).uniqueResult();
		return maxSortOrder;
	}

}
